﻿using System;
using System.Windows;
using Microsoft.Win32;

namespace TfsUtils.Ui.Mvvm.SystemLayer.Concrete
{
	public class SystemDialogs : ISystemDialogs
	{
		private OpenFileDialog _openFileDialog;

		#region ISystemDialogs Members

		public string OpenSingleFile()
		{
			_openFileDialog = new OpenFileDialog();
			_openFileDialog.CheckFileExists = true;
			_openFileDialog.Multiselect = false;
			var result = _openFileDialog.ShowDialog();
			if ( result != null && result.Value == true)
			{
				return _openFileDialog.FileName;
			}
			return null;
			
		}

        public void ShowMessageBox(string message, string caption, MessageBoxImage icon)
        {
            //UiCommunication.ShowMessage(message, caption, icon);
        }

        public void ShowValidationFailure(string message)
        {
            ShowMessageBox(message, "Validation failed", MessageBoxImage.Warning);
        }

	    public void ShowError(string message)
	    {
            ShowMessageBox(message, "Error", MessageBoxImage.Error  );
	    }

	    public bool AskQuestion(string questionText)
	    {
	        return MessageBox.Show(
	            questionText,
	            "Question",
	            MessageBoxButton.YesNo,
	            MessageBoxImage.Question) == MessageBoxResult.Yes;
	    }

	    #endregion
	}
}
